# !/usr/bin/env python
# encoding: utf-8


"""
  @author: gaogao
  @file: save_set_info_2_yaml.py
  @time: 2022/5/7 9:17
  @desc:
"""

from ruamel.yaml import YAML
from ruamel import yaml
from collections import namedtuple
from utils.log_util import loggings


def save_set_info_2_yaml(path_file="static/gui_setting.yaml", data_list=None):
    try:
        with open(path_file, mode='w+', encoding='utf-8') as file:
            yaml.dump(data_list, file)
    except Exception as e:
        loggings.error("save_set_info_2_yaml:"+str(e))


def read_yaml(path_file="D:\PyCharmProject\HC_ATS\static\gui_setting.yaml"):
    try:
        with open(path_file, "r", encoding='utf-8') as f:
            content = yaml.load(f.read(), Loader=yaml.Loader)
            return content
    except Exception as e:
        loggings.error("read_yaml:" + str(e))


# test_data = {"user": ["user1", "user2", "user3"]}
# save_set_info_2_yaml(data_list=test_data)
# print(read_yaml())
